package gui;

import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Canvas;

public class InheritanceArrow extends Shape{
	private int Xstart;
	private int Ystart;
	private int Xend;
	private int Yend;
	
	public InheritanceArrow(int x1,int y1,int x2,int y2){  
		Xstart=x1;
		Ystart=y1;
		Xend=x2;
		Yend=y2;
		
	}


	@Override
	void DrawShape(Canvas canvas) {
		GC gc = new GC(canvas);
		int deltaX = Xend - Xstart;
		int deltaY = Yend - Ystart;
		double frac = 0.3;
		int x3=((Xstart + (int)((1-frac)*deltaX - frac*deltaY))+(Xstart + (int)((1-frac)*deltaX + frac*deltaY)))/2;
		int y3=((Ystart + (int)((1-frac)*deltaY - frac*deltaX)) + (Ystart + (int)((1-frac)*deltaY + frac*deltaX)))/2;

		//gc.drawLine(Xstart.intValue(),Ystart.intValue(),Xend.intValue(),Yend.intValue());
		gc.drawLine(Xstart,Ystart,x3,y3);
		gc.drawLine(Xstart + (int)((1-frac)*deltaX + frac*deltaY),
				Ystart + (int)((1-frac)*deltaY - frac*deltaX),
			   Xend, Yend);
		gc.drawLine(Xstart + (int)((1-frac)*deltaX - frac*deltaY),
				Ystart + (int)((1-frac)*deltaY + frac*deltaX),
			   Xend, Yend);
		gc.drawLine(Xstart + (int)((1-frac)*deltaX + frac*deltaY),Ystart + (int)((1-frac)*deltaY - frac*deltaX),Xstart + (int)((1-frac)*deltaX - frac*deltaY),
				Ystart + (int)((1-frac)*deltaY + frac*deltaX));

		
	}

}
